<template>
  <div class="app-container bg-gray">
    <el-card class="box-1">
      <div class="header">
        <div>
          <span>销售每日可添加客户数：</span>
          <el-input :disabled="limitEdit" v-model="limit" size="mini" class="search-input" />
          <el-button :icon="limitEdit?'el-icon-edit':''" :type="limitEdit?'info':'success'" :class="limitEdit?'':'bg-green'" size="mini" @click="limitEdit=!limitEdit">{{ limitEdit?'':'保存' }}</el-button>
        </div>
        <div>
          <span>临时调额额度：</span>
          <el-input :disabled="temporaryEdit" v-model="temporaryLimit" size="mini" class="search-input" />
          <el-button :icon="temporaryEdit?'el-icon-edit':''" :type="temporaryEdit?'info':'success'" :class="temporaryEdit?'':'bg-green'" size="mini" @click="temporaryEdit=!temporaryEdit">{{ temporaryEdit?'':'保存' }}</el-button>
        </div>
        <div>
          <el-button type="success" class="bg-green" icon="el-icon-plus">批量同意</el-button>
          <el-button type="danger" icon="el-icon-delete">批量拒绝</el-button>
        </div>
      </div>
      <el-table :data="tableData" border @selection-change="handleSelectionChange">
        <el-table-column type="selection" width="50" header-align="center" align="center" />
        <el-table-column prop="name" label="姓名" min-width="120" header-align="center" align="center" />
        <el-table-column prop="department" label="部门" min-width="100" header-align="center" align="center" />
        <el-table-column prop="count" label="已申请次数" min-width="100" header-align="center" align="center" />
        <el-table-column prop="date" label="申请时间" min-width="150" header-align="center" align="center" />
        <el-table-column label="客户沟通情况" min-width="120" header-align="center" align="center">
          <template slot-scope="scope">
            <el-button type="primary" size="small" icon="el-icon-search" circle @click="dialogVisible=true"/>
          </template>
        </el-table-column>
        <el-table-column label="操作" min-width="200" header-align="center" align="center">
          <template slot-scope="scope">
            <el-button type="success" size="small" icon="el-icon-check" class="bg-green" circle />
            <el-button type="danger" size="small" icon="el-icon-close" circle />
          </template>
        </el-table-column>
      </el-table>
    </el-card>

    <el-dialog :visible.sync="dialogVisible" title="已添加客户沟通情况" width="400" class="dialog" center>
      <div class="content">
        <el-table :data="tableData2" border @selection-change="handleSelectionChange">
          <el-table-column type="selection" width="50" header-align="center" align="center" />
          <el-table-column prop="name" label="客户昵称" min-width="100" header-align="center" align="center" />
          <el-table-column prop="date" label="最近联系时间" min-width="150" header-align="center" align="center" sortable />
          <el-table-column prop="contact_value" label="沟通内容" min-width="250" header-align="center" align="center" show-overflow-tooltip />
        </el-table>
        <el-pagination :current-page.sync="currentPage" :page-size="pageSize" :total="total" class="pagination" layout="total, prev, pager, next, jumper" @current-change="handleCurrentChange" />
      </div>
    </el-dialog>
  </div>
</template>

<script>
export default {
  data() {
    return {
      // 弹窗显示
      dialogVisible: false,
      // 公海额度输入框
      limitEdit: true,
      limit: 10,
      // 公海临时额度输入框
      temporaryEdit: true,
      temporaryLimit: 10,
      // table多选选择数组
      multipleSelection: [],

      currentPage: 1,
      pageSize: this.$store.getters.userInfo.pageSize,
      total: 30,

      transfer: {
        id: '',
        where: 0,
        toId: ''
      },

      tableData: [{
        name: '朱峰',
        department: '网商',
        count: 5,
        date: '19:00:00'
      }, {
        name: '朱峰',
        department: '网商',
        count: 5,
        date: '19:00:00'
      }, {
        name: '朱峰',
        department: '网商',
        count: 5,
        date: '19:00:00'
      }, {
        name: '朱峰',
        department: '网商',
        count: 5,
        date: '19:00:00'
      }, {
        name: '朱峰',
        department: '网商',
        count: 5,
        date: '19:00:00'
      }, {
        name: '朱峰',
        department: '网商',
        count: 5,
        date: '19:00:00'
      }, {
        name: '朱峰',
        department: '网商',
        count: 5,
        date: '19:00:00'
      }],
      tableData2: [{
        name: '朱峰',
        date: '19:00:00',
        contact_value: '今天天气不错,适合销售'
      }, {
        name: '朱峰',
        date: '19:00:00',
        contact_value: '今天天气不错,适合销售'
      }, {
        name: '朱峰',
        date: '19:00:00',
        contact_value: '今天天气不错,适合销售'
      }, {
        name: '朱峰',
        date: '19:00:00',
        contact_value: '今天天气不错,适合销售'
      }, {
        name: '朱峰',
        date: '19:00:00',
        contact_value: '今天天气不错,适合销售'
      }, {
        name: '朱峰',
        date: '19:00:00',
        contact_value: '今天天气不错,适合销售'
      }, {
        name: '朱峰',
        date: '19:00:00',
        contact_value: '今天天气不错,适合销售'
      }]
    }
  },
  watch: {

  },
  methods: {
    handleSizeChange(val) {
      // console.log(`每页 ${val} 条`)
    },
    handleCurrentChange(val) {
      // console.log(`当前页: ${val}`)
    },
    toggleSelection(rows) {
      if (rows) {
        rows.forEach(row => {
          this.$refs.multipleTable.toggleRowSelection(row)
        })
      } else {
        this.$refs.multipleTable.clearSelection()
      }
    },
    handleSelectionChange(val) {
      this.multipleSelection = val
    }
  }
}
</script>

<style lang="scss" type="text/scss" scoped>
@import '../../../styles/index.scss';
.box-1 {
  .header {
    > div {
      @include flex-row(center, flex-start);
      padding: 10px 0;
      flex-wrap: wrap;
      .el-input {
        width: 120px;
        margin-right:10px;
      }
    }
  }
}
.dialog {
  .content {
    text-align: center;
    .text {
      padding-bottom: 20px;
      .el-radio-group {
        padding-left: 15px;
      }
    }
  }
}
</style>
